"""
0527上午-演示代码
"""
# print('早上好','我是','王瑾琪')
#
# text = 'xxxx'
# print('日志---》',text)
#
# int_a = -1000
# print(type(int_a))
# print(int_a)
#
# float_b = 1.11
# print(type(float_b))
# print(float_b)
# float_b = 3
# print(type(float_b))
# print(float_b)
# float_b = '3'
# print(type(float_b))
# print(float_b)
# + - * /  **  %
# 加法
# sum_a = 1 + 3.22
# # round四舍五入
# print(round(sum_a))
# # 打印变量的数据类型
# print(type(sum_a))
# print(sum_a)
# # 减法
# param_b = 3-1
# print(param_b)
# # 乘法
# param_c = 3 * 3
# print(param_c)
# # 除法
# param_d = 4 / 2
# print(type(param_d))
# print(param_d)
# # 乘方
# param_e = 4 ** 2
# print(param_e)
# # 取余
# param_f = 3 % 2
# print(param_f)

# 字符串
# 忽视转义
# str_a = r"hello\nworld"
# print(str_a)

# 格式化
# text = '你好，%s'
# print(text%'张三')
# 使用format方式格式化
# text1 = '你好，{}'.format('王瑾琪')
# print(text1)
# name = '王瑾琪'
# text2 = f'你好，{name}'
# print(text2)
# text = '自动化'
# xpath = "//div[text()='']".format(text)
# 字符串 索引 从0开始
# str_c = 'abcdef'
# print(str_c[-1])
# # 字符串 切片
# print(str_c[1:])
# # 字符串 切片 截取bcd
# # 前闭后开 [1:3] =  1<=str<3
# print(str_c[1:4])
# # 字符串 切片 截取bdf
# print(str_c[1:-2:2])

# # 布尔值 bool
# bool_true = True
# bool_false = False
# # =是赋值 ==是等于 !=是不等于
# print(1==1)
# print(1!=1)
# if 1 == 1:
#     print('进入条件语句')

# 列表 list
# 创建一个列表
# fruit = ['apple', 'orange', 'banana']
# print(fruit)
# 列表-索引:取出apple
# print(fruit[0])
# len() 获取列表长度
# print(len(fruit))
# list是一个可变的有序表，可以往list中追加元素到末尾
# fruit.append('lemon')
# print(fruit)
# # 删除末尾的元素
# fruit.pop(0)
# print(fruit)
# 将apple换成pear
# fruit[0] = 'pear'
# print(fruit)
# 列表中可存储的数据类型
# list_b = ['a',1,2.11,['b'],{'key':'value'},True]
# print(list_b)

# 元祖
# fruit = ('apple','orange','banana')
# print(fruit)
# fruit_1 = (['apple','orange','banana'],[1,2,3])
# print(fruit_1)
# fruit_1[0][0] = 'pear'
# print(fruit_1)

# 字典
# 新建一个字典
# dict_a = {'name': '王瑾琪', 'age': 28, 'sex': 'male'}
# print(dict_a)
# 取name的值
# print(dict_a['name'])
# print(dict_a.get('age'))
# 当key不存在时，使用get方法，不会报错，并且返回一个None
# print(dict_a['aa'])
# print(dict_a.get('aa'))
# # 在字典中添加一个键值对
# dict_a['height'] = 183
# print(dict_a)
# # 删除height
# dict_a.pop('height')
# print(dict_a)
# 获取字典中所有的key
# print(dict_a.keys())
# # 获取字典中所有的value
# print(dict_a.values())
# # 获取字典中所有的keys和values
# for keys in dict_a.keys():
#     print(keys)
# print(values)

# 集合
# 新建一个集合
# s = set([1, 1, 2, 2, 3, 3])
# print(s)

# 判断 if
# a = 10
# if a > 11:
#     print('进入循环')

# if-else
# age = 40
# if age >= 18:
#     print('your age is', age)
#     print('adult')
# else:
#     print('your age is', age)
#     print('teenager')

# if-elif-else
# age = 17
# if age >= 18:
#     print('adult')
# elif age >= 6:
#     print('teenager')
# else:
#     print('kid')

# 多条件判断
# age = 40
# sex = 'female'
# if age >= 18 or sex == 'male':
#     print('your age is', age)
#     print('adult')
# else:
#     print('your age is', age)
#     print('teenager')
# 使用in 进行条件判断
# text = '这是个？？'
# if '系统' in text:
#     print('进入循环')
# else:
#     print('不存在系统两字')

# for循环
# 依次打印列表中的人名
# names = ['Michael', 'Bob', 'Tracy']
# for name in names:
#     print(name)
# range()
# 依次打印整数0-4  [0,1,2,3,4]
# for number in range(5):
#     print(number)
# 依次打印字段的键值对
# d = {'Bob': 1, 'Lisa': 2, 'Mary': 3}
# for k, v in d.items():
#     print(k)
#     print(v)

# while 循环
# 打印 0-9
# n = 0
# while n < 10:
#     print(n)
#     n += 1
# n = n + 1

# 当n=3时，退出循环
# n = 0
# while n < 10:
#     print(n)
#     n += 1
#     if n == 3:
#         break

# 打印10以内的奇数
# n = 0
# while n < 10:
#     n += 1
#     if n % 2 == 0:
#         continue
#     print(n)

# try-except异常处理
# try:
#     dict_a = {'name': '王瑾琪', 'age': 28, 'sex': 'male'}
#     print(dict_a['aa'])
# except:
#     # try中报错，则执行except
#     print('try中语句执行异常，进入except')
# else:
#     # try中语句正确执行后，会执行else语句
#     print('try中语句正确执行，进入else')
# finally:
#     # 无论try中语句是否正确执行，最终都会执行finally语句
#     print('我是finally')
